import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { listSelectData } from '/@/api/m8/flow/flow';

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('图纸流程选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 80,
  schemas: [
    {
      label: '图纸ID',
      field: 'picId',
      component: 'Input',
      show: false,
    },
    {
      label: '用户编码',
      field: 'userCode',
      component: 'Input',
      show: false,
    },
    {
      label: '业务类型',
      field: 'type',
      component: 'Input',
      show: false,
    },
  ],
};
const tableColumns: BasicColumn[] = [
  {
    title: t('图名'),
    dataIndex: 'orderPic.picname',
    key: 'pic.picname',
    sorter: true,
    width: 150,
    slot: 'firstColumn',
  },
  {
    title: t('加工顺序'),
    dataIndex: 'sortNum',
    key: 'a.sort_num',
    sorter: true,
    width: 80,
  },
  {
    title: t('工序'),
    dataIndex: 'oper.operName',
    key: 'a.oper_code',
    sorter: true,
    width: 80,
  },
  {
    title: t('数量'),
    dataIndex: 'iqty',
    key: 'a.iqty',
    sorter: true,
    width: 80,
  },
  {
    title: t('累计完工'),
    dataIndex: 'overQty',
    sorter: false,
    width: 80,
  },
  {
    title: t('累计补料'),
    dataIndex: 'moreQty',
    sorter: false,
    width: 80,
  },
  {
    title: t('状态'),
    dataIndex: 'flowStatus',
    sorter: false,
    width: 100,
    dictType: 'M8_order_status',
  },
];

const tableProps: BasicTableProps = {
  api: listSelectData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'id',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'id',
  itemName: 'sortNum',
};
